import axios from 'axios'
axios.defaults.headers.post['Content-type'] = 'application/json'
// 搜索自动补充
export const SearchAuto = params => {
  return axios.get('/api/book/fuzzy-search', {params: params}).then(res => res.data)
}
// 获取搜索热词
export const SearchHotWords = params => {
  return axios.get('/api/book/search-hotwords', {params: params}).then(res => res.data)
}

// 获取所有分类
export const Category = params => {
  return axios.get('/api/cats/lv2/statistics', {params: params}).then(res => res.data)
}
// 获取分类下小类别
export const Categorylist = params => {
  return axios.get('/api/cats/lv2', {params: params}).then(res => res.data)
}
// 根据分类获取小说列表
export const CategorylistBook = params => {
  return axios.get('/api/book/by-categories', {params: params}).then(res => res.data)
}
// 获取小说信息
export const Bookinfo = params => {
  return axios.get('/api/book/' + params).then(res => res.data)
}
// 获取小说正版源于盗版
export const Booksources = params => {
  return axios.get('/api/atoc', {params: params}).then(res => res.data)
}
// 获取小说章节（根据小说源 id）
export const Bookcatalog = params => {
  return axios.get('/api/atoc/' + params + '?view=chapters').then(res => res.data)
}
/** ================排行榜===================== */
// 获取排行榜 小说
export const Ranklistbook = params => {
  return axios.get('/api/ranking/' + params).then(res => res.data)
}
// 获取 排行榜类型
export const Rankcategory = params => {
  return axios.get('/api/ranking/gender', {params: params}).then(res => res.data)
}
// 获取小说章节内容
export const Bookchapter = params => {
  return axios.get('/chapter/' + encodeURIComponent(params)).then(res => res.data)
}
